package com.faxsun.core.persist.entity;

import java.io.Serializable;
import java.util.Comparator;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "fx_livemsg")
public class LiveMsgPO implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -8092013915122893993L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private long id;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "channel_id")
	private LivePO channel;

	/**
	 * 存储json格式字符串 <pre>
	 * {
	 *     "text":"",
	 *     "img":[
	 *         {"url":""}，
	 *         {"url":""}
	 *     ]
	 * }
	 * 
	 * </pre>
	 * 
	 */
	private String content;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "sender_id")
	private UserPO sender;

	private Date date;
	
	/**
	 * 点赞次数
	 */
	private int thumbsup;
	
	/**
	 * 评论次数
	 */
	private int comments;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public LivePO getChannel() {
		return channel;
	}

	public void setChannel(LivePO channel) {
		this.channel = channel;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public UserPO getSender() {
		return sender;
	}

	public void setSender(UserPO sender) {
		this.sender = sender;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}
    
    public static class Comparators {
        public static Comparator<LiveMsgPO> DFLT_ID_DESC = new Comparator<LiveMsgPO>() {
            @Override
            public int compare(LiveMsgPO o1, LiveMsgPO o2) {
                return (int)(o2.id - o1.id);
            }
        };
    }

	public int getThumbsup() {
		return thumbsup;
	}

	public void setThumbsup(int thumbsup) {
		this.thumbsup = thumbsup;
	}

	public int getComments() {
		return comments;
	}

	public void setComments(int comments) {
		this.comments = comments;
	}
    
    
}
